package mysql

import (
	"gorm.io/gorm"
	"mouth-project/global"
)

//订单表

type Order struct {
	gorm.Model
	UserId   int64   `gorm:"type:int(10);comment:用户Id"`
	GoodsId  int64   `gorm:"type:int(10);comment:商品Id"`
	OrderSn  string  `gorm:"type:varchar(50);comment订单号"`
	SumPrice float64 `gorm:"type:decimal(10,2);comment:总价"`
	BuyNum   int64   `gorm:"type:varchar(256);comment:购买数量"`
	Payment  int     `gorm:"type:tinyint(1);comment:支付方式 1 微信 2 支付宝"`
}

//创建订单

func (o *Order) Create() error {
	return global.Db.Create(&o).Error
}

//订单详情

func (o *Order) Details() error {
	return global.Db.Where("id = ?", o.ID).Find(&o).Limit(1).Error
}
